import time
from loguru import logger
import os

BasePath = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__))))
t = time.strftime("%Y_%m_%d")

log_file = os.path.join(BasePath, 'app_log_{}.log'.format(t))
log_format = "<green>{time:YYYY-MM-DD HH:mm:ss}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>"

logger.add(log_file, rotation="500MB", encoding="utf-8", enqueue=True, retention="10 days", format=log_format)

forge_logger = logger

if __name__ == '__main__':
    forge_logger.info("中文test")
    forge_logger.debug("中文test")
    forge_logger.warning("中文test")
    forge_logger.error("中文test")
    forge_logger.critical("critical")
    logger.info('If you are using Python {}, prefer {feature} of course!', 3.6, feature='f-strings')
    n1 = "cool"
    n2 = [1, 2, 3]
    logger.info(f'If you are using Python {n1}, prefer {n2} of course!')
